/*!
 * \file GapStateBase.h
 * \brief Base class for all states in state machine for
 * GAP protocol in Media Gateway
 */

#ifndef MGW_GAP_STATE_BASE_H
#define MGW_GAP_STATE_BASE_H

#include "StateBase.h"
#include "GapGenerator.h"
#include "GapEventConnectCfm.h"
#include "GapEventConnectRej.h"
#include "GapEventT709Expired.h"
#include "GapEventT711Expired.h"
#include "GapEventEchoReq.h"
#include "GapEventMediaBearerSetupReq.h"
#include "GapEventMediaBearerRelease.h"

namespace tsc
{
namespace mgw
{

using common::EventData;

/**
 * Base class for GAP states in Media Gateway
 */
class GapStateBase : public common::StateBase
{
public:

	/**
	 * Handle specified event for the specified generator.
	 * When the event is handled by state it should be deleted
	 *
	 * \param generator the generator for which the event occurred
	 * \param event the event to handle
	 */
    virtual
	void handleEvent(common::Generator*  generator,
	                 common::EventData*& event);

	/**
     * Checks if transmission to SGW associated with this generator
     * is possible in this state
     */
    virtual bool txEnabled() const;

protected:
	/**
	 * Creates new GAP state with specified name
	 * \param name the name of state
	 */
	GapStateBase(const char* name);

	virtual ~GapStateBase();

    virtual void
    handleEventGapConnectRej(
        GapGenerator* gapGen,
        GapEventConnectRej* event,
        EventData*& eventData);

    virtual void
    handleEventGapConnectCfm(
        GapGenerator* gapGen,
        GapEventConnectCfm* event,
        EventData*& eventData);

	virtual void
	handleEventGapT709Expired(
        GapGenerator* gapGen,
        GapEventT709Expired* event,
        EventData*& eventData);

    virtual void
    handleEventGapT711Expired(
        GapGenerator* gapGen,
        GapEventT711Expired* event,
        EventData*& eventData);

    virtual void
    handleEventGapEchoReq(
        GapGenerator* gapGen,
        GapEventEchoReq* event,
        EventData*& eventData);

    virtual void
    handleEventGapMediaBearerSetupReq(
        GapGenerator* gapGen,
        GapEventMediaBearerSetupReq* event,
        EventData*& eventData);

    virtual void
    handleEventGapMediaBearerRelease(
        GapGenerator* gapGen,
        GapEventMediaBearerRelease* event,
        EventData*& eventData);
};

} // namespace mgw
} // namespace tsc

#endif // MGW_GAP_STATE_BASE_H
